
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';

import { AssetService } from './assetService';
import { map } from 'rxjs/operators';
import { AssetType } from '../models/AssetType';

@Injectable()
export class AssetTypeService implements Resolve<AssetType[] | AssetType[][]> {

  constructor(private assetService: AssetService) {}

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<AssetType[] | AssetType[][]>  {
    return this.assetService.getAssetTypes().pipe(map(res => {
      return  res.res;
    }));
  }
}

